package edu.guet.server.utils;

import org.json.JSONException;
import org.json.JSONObject;
import edu.guet.server.utils.HttpUtil;

import java.net.URLEncoder;

import java.net.URLEncoder;

public class SensitiveUtils {
    public static String SensitiveUtils(String s) {
        // 请求url
        String url = "https://aip.baidubce.com/rest/2.0/solution/v1/text_censor/v2/user_defined";
        try {
            String param = "text=" + URLEncoder.encode(s, "utf-8");

            // 注意这里仅为了简化编码每一次请求都去获取access_token，线上环境access_token有过期时间， 客户端可自行缓存，过期后重新获取。
            String accessToken ="24.a7805b5cc8c1c404a1aec9774b9d6244.2592000.1729344942.282335-115634259";

            String result = HttpUtil.post(url, accessToken, param);
            System.out.println(result);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    public static boolean isCompliant(String jsonData) {
        if(jsonData.charAt(15)=='不'){
            return false;
        }
        else
            return true;
    }
}
